# eric7.MicroPython.Devices.Nrf52Devices

Module implementing the device interface class for NRF52 boards with UF2 support.

### Global Attributes

None

### Classes

Nrf52Device | Class implementing the device for NRF52 boards with UF2 support.

### Functions

createDevice | Function to instantiate a MicroPython device object.

## Nrf52Device

Class implementing the device for NRF52 boards with UF2 support.

### Derived from

BaseDevice

### Class Attributes

None

### Class Methods

None

### Methods

Nrf52Device | Constructor
__activateBootloader | Private slot to switch the board into 'bootloader' mode.
__createNrfMenu | Private method to create the NRF52 submenu.
__firmwareVersionResponse | Private slot handling the response of the latest version request.
__flashPython | Private slot to flash a MicroPython firmware to the device.
__resetDevice | Private slot to reset the connected device.
__showFirmwareVersions | Private slot to show the firmware version of the connected device and the available firmware version.
activateBluetoothInterface | Public method to activate the Bluetooth interface.
addDeviceMenuEntries | Public method to add device specific entries to the given menu.
canRunScript | Public method to determine, if a script can be executed.
canStartFileManager | Public method to determine, if a File Manager can be started.
canStartPlotter | Public method to determine, if a Plotter can be started.
canStartRepl | Public method to determine, if a REPL can be started.
deactivateBluetoothInterface | Public method to deactivate the Bluetooth interface.
deviceName | Public method to get the name of the device.
forceInterrupt | Public method to determine the need for an interrupt when opening the serial connection.
getBluetoothStatus | Public method to get Bluetooth status data of the connected board.
getDeviceScan | Public method to perform a Bluetooth device scan.
getDocumentationUrl | Public method to get the device documentation URL.
getDownloadMenuEntries | Public method to retrieve the entries for the downloads menu.
hasBluetooth | Public method to check the availability of Bluetooth.
hasFlashMenuEntry | Public method to check, if the device has its own flash menu entry.
runScript | Public method to run the given Python script.
setButtons | Public method to enable the supported action buttons.
supportsDeviceScan | Public method to indicate, that the Bluetooth implementation supports scanning for devices.

### Static Methods

None

#### Nrf52Device (Constructor)

Nrf52Device(microPythonWidget, deviceType, parent=None)

Constructor

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  device type assigned to this device interface
parent (QObject)
  reference to the parent object

#### Nrf52Device.__activateBootloader

__activateBootloader()

Private slot to switch the board into 'bootloader' mode.

#### Nrf52Device.__createNrfMenu

__createNrfMenu()

Private method to create the NRF52 submenu.

#### Nrf52Device.__firmwareVersionResponse

__firmwareVersionResponse(reply)

Private slot handling the response of the latest version request.

reply (QNetworkReply)
  reference to the reply object

#### Nrf52Device.__flashPython

__flashPython()

Private slot to flash a MicroPython firmware to the device.

#### Nrf52Device.__resetDevice

__resetDevice()

Private slot to reset the connected device.

#### Nrf52Device.__showFirmwareVersions

__showFirmwareVersions()

Private slot to show the firmware version of the connected device and the available firmware version.

#### Nrf52Device.activateBluetoothInterface

activateBluetoothInterface()

Public method to activate the Bluetooth interface.

Return:
  flag indicating the new state of the Bluetooth interface

Return Type:
  bool

Raises OSError:
  raised to indicate an issue with the device

#### Nrf52Device.addDeviceMenuEntries

addDeviceMenuEntries(menu)

Public method to add device specific entries to the given menu.

menu (QMenu)
  reference to the context menu

#### Nrf52Device.canRunScript

canRunScript()

Public method to determine, if a script can be executed.

Return:
  tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### Nrf52Device.canStartFileManager

canStartFileManager()

Public method to determine, if a File Manager can be started.

Return:
  tuple containing a flag indicating it is safe to start a File Manager and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### Nrf52Device.canStartPlotter

canStartPlotter()

Public method to determine, if a Plotter can be started.

Return:
  tuple containing a flag indicating it is safe to start a Plotter and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### Nrf52Device.canStartRepl

canStartRepl()

Public method to determine, if a REPL can be started.

Return:
  tuple containing a flag indicating it is safe to start a REPL and a reason why it cannot.

Return Type:
  tuple of (bool, str)

#### Nrf52Device.deactivateBluetoothInterface

deactivateBluetoothInterface()

Public method to deactivate the Bluetooth interface.

Return:
  flag indicating the new state of the Bluetooth interface

Return Type:
  bool

Raises OSError:
  raised to indicate an issue with the device

#### Nrf52Device.deviceName

deviceName()

Public method to get the name of the device.

Return:
  name of the device

Return Type:
  str

#### Nrf52Device.forceInterrupt

forceInterrupt()

Public method to determine the need for an interrupt when opening the serial connection.

Return:
  flag indicating an interrupt is needed

Return Type:
  bool

#### Nrf52Device.getBluetoothStatus

getBluetoothStatus()

Public method to get Bluetooth status data of the connected board.

Return:
  list of tuples containing the translated status data label and the associated value

Return Type:
  list of tuples of (str, str)

Raises OSError:
  raised to indicate an issue with the device

#### Nrf52Device.getDeviceScan

getDeviceScan(timeout=10)

Public method to perform a Bluetooth device scan.

timeout (int (optional))
  duration of the device scan in seconds (defaults to 10)

Return:
  tuple containing a dictionary with the scan results and an error string

Return Type:
  tuple of (dict, str)

#### Nrf52Device.getDocumentationUrl

getDocumentationUrl()

Public method to get the device documentation URL.

Return:
  documentation URL of the device

Return Type:
  str

#### Nrf52Device.getDownloadMenuEntries

getDownloadMenuEntries()

Public method to retrieve the entries for the downloads menu.

Return:
  list of tuples with menu text and URL to be opened for each entry

Return Type:
  list of tuple of (str, str)

#### Nrf52Device.hasBluetooth

hasBluetooth()

Public method to check the availability of Bluetooth.

Return:
  flag indicating the availability of Bluetooth

Return Type:
  bool

Raises OSError:
  raised to indicate an issue with the device

#### Nrf52Device.hasFlashMenuEntry

hasFlashMenuEntry()

Public method to check, if the device has its own flash menu entry.

Return:
  flag indicating a specific flash menu entry

Return Type:
  bool

#### Nrf52Device.runScript

runScript(script)

Public method to run the given Python script.

script (str)
  script to be executed

#### Nrf52Device.setButtons

setButtons()

Public method to enable the supported action buttons.

#### Nrf52Device.supportsDeviceScan

supportsDeviceScan()

Public method to indicate, that the Bluetooth implementation supports scanning for devices.

Return:
  flag indicating that the scanning function is supported

Return Type:
  bool

Up

## createDevice

createDevice(microPythonWidget, deviceType, _vid, _pid, _boardName, _serialNumber)

Function to instantiate a MicroPython device object.

microPythonWidget (MicroPythonWidget)
  reference to the main MicroPython widget
deviceType (str)
  device type assigned to this device interface
_vid (int)
  vendor ID (unused)
_pid (int)
  product ID (unused)
_boardName (str)
  name of the board (unused)
_serialNumber (str)
  serial number of the board (unused)

Return:
  reference to the instantiated device object

Return Type:
  RP2Device

Up